#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
监控API
"""

from fastapi import APIRouter
from typing import Dict, Any
from datetime import datetime

from app.services.stream_monitor import get_stream_monitor

router = APIRouter()

# 创建流监控实例
stream_monitor = get_stream_monitor()

@router.get("/stats")
async def get_monitor_stats() -> Dict[str, Any]:
    """获取监控统计信息"""
    try:
        # 获取流统计信息
        stats = await stream_monitor.check_all_streams()
        
        return {
            "timestamp": datetime.now().isoformat(),
            "streams": stats,
            "monitor_status": {
                "is_running": stream_monitor.is_running,
                "check_interval": stream_monitor.check_interval,
                "max_concurrent_checks": stream_monitor.max_concurrent_checks
            }
        }
    except Exception as e:
        return {
            "error": str(e),
            "timestamp": datetime.now().isoformat()
        }